<?php
if (!$model->parentId) {
	$this->breadcrumbs = array(
		'凭证科目' => array(
			'index'
		),
		$model->name,
	);
} else {
	$parent = $model;
	while ($parent = $parent->parent) {
		$breadcrumbs[$parent->name] = array(
			'admin',
			'parentId' => $parent->id
		);
	}
	$breadcrumbs['管理'] = array(
		'admin',
	);
	$breadcrumbs['凭证科目'] = array(
		'index'
	);
	$this->breadcrumbs = array_reverse($breadcrumbs, true);
}

if (Yii::app()->user->checkAccess('accountTokenManage')) {
	$this->userActions = array(
		//array('label'=>'List AccountTokenCategory', 'url'=>array('index')),
		array(
			'label' => '新建子科目',
			'url' => array(
				'create',
				'parentId' => $model->id
			)
		),
		array(
			'label' => '新建同级科目',
			'url' => $model->parentId ? array(
					'create',
					'parentId' => $model->parentId
				) : array(
					'create'
				)
		),
		array(
			'label' => '更新',
			'url' => array(
				'update',
				'id' => $model->id
			)
		),
		array(
			'label' => '删除',
			'url' => '#',
			'linkOptions' => array(
				'submit' => array(
					'delete',
					'id' => $model->id
				),
				'confirm' => '确定要删除这个科目么？'
			)
		),
		array(
			'label' => '管理同级科目',
			'url' => $model->parentId ? array(
					'admin',
					'parentId' => $model->parentId
				) : array(
					'admin'
				)
		),
		array(
			'label' => '管理子科目',
			'url' => array(
				'admin',
				'parentId' => $model->id
			)
		),
		array(
			'label' => '编辑初始借贷',
			'url' => array(
				'accountTokenInitial/update',
				'categoryId' => $model->id
			)
		),
	);
}
?>

<h1>查看科目 <?php echo $model->name; ?></h1>
<?php $this
	->widget('zii.widgets.CDetailView',
		array(
			'data' => $model,
			'attributes' => array(
				'id',
				array(
					'name' => 'parentId',
					'type' => 'raw',
					'value' => CHtml::link($model->parent->displayLongName,
						array(
							'view',
							'id' => $model->parentId
						)),
				),
				'name',
				array(
					'name' => 'initial.debit',
					'type' => 'currency',
				),
				array(
					'name' => 'initial.credit',
					'type' => 'currency',
				),
				'createTime',
				array(
					'name' => 'createUserId',
					'type' => 'raw',
					'value' => $model->createUserId ? $model->createUser->employee->fullName : ''
				),
				'updateTime',
				array(
					'name' => 'updateUserId',
					'type' => 'raw',
					'value' => $model->updateUserId ? $model->updateUser->employee->fullName : ''
				),
			),
		));
?>
